package com.xxg.renrenorder.dao;

import com.mongodb.client.MongoCollection;
import com.mongodb.client.model.IndexOptions;
import com.mongodb.client.model.Indexes;
import com.xxg.renrencommon.domain.bean.CarryProductInfo;
import com.xxg.renrencommon.domain.filedenum.productenum.CarryProductStatusEnum;
import org.bson.Document;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
import static org.springframework.data.mongodb.core.query.Criteria.where;

/**
 * 带货信息dao
 *
 * @author szj
 * @date 2021/11/29
 */
@Repository
public class CarryProductInfoDao {
    private final MongoTemplate mongoTemplate;

    public CarryProductInfoDao(MongoTemplate mongoTemplate) {
        this.mongoTemplate = mongoTemplate;
    }


    public CarryProductInfo findByCarrySpuId(Integer carrySpuId) {
        Query query = new Query(where("carrySpuId").is(carrySpuId));
        return mongoTemplate.findOne(query, CarryProductInfo.class);
    }

    public List<CarryProductInfo> findBySpuId(Integer spuId) {
        Query query = new Query(where("spuId").is(spuId));
        return mongoTemplate.find(query, CarryProductInfo.class);
    }
}
